package org.jivesoftware.spark.component;

import java.awt.Color;
import java.awt.Insets;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.Action;
import javax.swing.Icon;

import org.jivesoftware.Spark;

public class LoginDialogButton extends RolloverButton{
	 /**
     * Create a new LoginDialogButton.
     */
    public LoginDialogButton() {
        decorate();
    }

    public LoginDialogButton(String text) {
        super(text);
        decorate();
    }

    public LoginDialogButton(Action action) {
        super(action);
        decorate();
    }

    /**
     * Create a new LoginDialogButton.
     *
     * @param icon the icon to use on the button.
     */
    public LoginDialogButton(Icon icon) {
        super(icon);
        decorate();
    }

    /**
     * Create a new LoginDialogButton.
     *
     * @param text the button text.
     * @param icon the button icon.
     */
   public LoginDialogButton(String text, Icon icon) {
        super(text, icon);
        decorate();
    }


    /**
     * Decorates the button with the approriate UI configurations.
     */
    private void decorate() {
        setBorderPainted(false);
        setOpaque(false);

        setContentAreaFilled(false);
        setMargin(new Insets(1, 0, 1, 0));


        addMouseListener(new MouseAdapter() {
            String str;
            public void mouseEntered(MouseEvent e) {
                if (isEnabled()) {
                    setBorderPainted(true);

                    // Handle background border on mac.
                    if (!Spark.isMac()) {
                    	//TODO
//                        setContentAreaFilled(true);
                    	setContentAreaFilled(false);
                    	str=getText();
//                    	setText("<html><u><font color=#000000>"+str+"<u>");
                    	setForeground(Color.BLUE);
                    }
                }
            }

            public void mouseExited(MouseEvent e) {
                setBorderPainted(false);
                setContentAreaFilled(false);
                setText(str);
                setForeground(Color.BLACK);
            }
        });

    }

}
